<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>统计字母 r 的数量</title>
</head>

<body>
  <label for="str1">请输入第一个字符串：</label>
  <input type="text" id="str1">
  <label for="str2">请输入第二个字符串：</label>
  <input type="text" id="str2">
  <button onclick="countR()">统计字母 r 的数量</button>
  <p id="result"></p >
  <script>
    function countR() {
      var str1 = document.getElementById('str1').value;
      var str2 = document.getElementById('str2').value;
      var count1 = (str1.match(/r/ig) || []).length;
      var count2 = (str2.match(/r/ig) || []).length;
      var totalCount = count1 + count2;
      document.getElementById('result').innerHTML = `字母 r 的总数量为: ${totalCount}`;
    }
  </script>
</body>

</html>